﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CYTS.Aoyou.Framework.Cache
{
    /// <summary>
    /// 缓存适配器的基类
    /// </summary>
    public class CacheAdapterBase
    {
        protected Dictionary<string, List<CacheConnection>> DicCacheConnection = new Dictionary<string, List<CacheConnection>>();

        protected readonly string Region = string.Empty;

        protected CacheAdapterBase(CacheProvider provider)
        {
            foreach (var conn in provider.CacheConnections)
            {
                if (!DicCacheConnection.ContainsKey(conn.Name))
                {
                    DicCacheConnection[conn.Name] = new List<CacheConnection>();
                }
                DicCacheConnection[conn.Name].Add(conn);
            }

            string typeName = this.GetType().Name;
            Region = typeName.Substring(0, typeName.IndexOf("CacheAdapter"));
        }
    }
}
